import pygame

import globalvars


class Selector(pygame.sprite.Sprite):
	"""A selector rectangle"""
	def __init__(self, owner):
		pygame.sprite.Sprite.__init__(self) # Initialize base class
		self.owner = owner
		self.image = pygame.Surface([owner.rect.width + 2, owner.rect.height + 2]).convert_alpha()
		self.image.fill([0, 0, 0, 0])
		self.rect = self.image.get_rect()
		self.rect.topleft = owner.rect.topleft
		self.rect.move_ip(-1, -1)
		pygame.draw.rect(self.image, [0, 0, 0], self.image.get_rect(), 1)
		globalvars.objects_draw.add(self)
		
	def update(self):
		self.rect.topleft = self.owner.rect.topleft
		self.rect.move_ip(-1, -1)
